from __future__ import print_function
from django.db import models


# /////////////////////////////////////////////////////////////////////////////
class MainWord(models.Model):
    """
    'Cat', 'Dog', etc. A placeholder, essentially
    """
    word = models.CharField(max_length=30, unique=True)
    pronunciation = models.FileField(upload_to="audio", blank=True, verbose_name='Sounds like')

    def __unicode__(self):
        return self.word

    class Meta:
        ordering = ['word']

# /////////////////////////////////////////////////////////////////////////////
class DefinitionPartOfSpeech(models.Model):
    """
    A DefinitionPartOfSpeech contains one distinct meaning of a MainWord.
    """
    FUNCTIONAL_LBL = (
        ('adj', 'adjective'),
        ('adv', 'adverb'),
        ('conj', 'conjunction'),
        ('intj', 'exclamation/interjection'),
        ('n', 'noun'),
        ('num', 'numeral'),
        ('prep', 'preposition'),
        ('pron', 'pronoun'),
        ('v', 'verb'),
    )
    word_clarification = models.CharField(max_length=30, blank=True)        # see a!.
    part_of_speech = models.CharField(max_length=5, choices=FUNCTIONAL_LBL)
    part_of_speech_alt = models.CharField(max_length=5, blank=True, choices=FUNCTIONAL_LBL)

    word_fk = models.ForeignKey(MainWord, verbose_name='Main Word')

    def __unicode__(self):
        return u"%s, %s" % (self.word_fk, self.part_of_speech)

    class Meta:
        verbose_name = "Part of speech"
        verbose_name_plural = "Part of speeches"
        ordering = ['word_fk']

# /////////////////////////////////////////////////////////////////////////////
class WordUsage(models.Model):
    """
    A WordUsage may be thought of as example.
    """
    main_definition = models.CharField(max_length=128, blank=True)
    synonym = models.CharField(max_length=24, blank=True)
    antonym = models.CharField(max_length=24, blank=True)
    sino_vietnamese = models.CharField(max_length=24, blank=True)
    french = models.CharField(max_length=24, blank=True)
    restricted = models.CharField(max_length=24, blank=True)
    noun_classifier = models.CharField(max_length=24, blank=True)    # classifier for the word in question. e.g. ao - ca'i ao; ca'i is a classifier

    vietnamese_phrase = models.CharField(max_length=128, blank=True)
    english_phrase = models.CharField(max_length=128, blank=True)
    part_of_speech_fk = models.ForeignKey(DefinitionPartOfSpeech, verbose_name='Word Definition')

    def __unicode__(self):
        return u"%s | %s %s" % (self.main_definition, self.vietnamese_phrase, self.english_phrase)

    class Meta:
        ordering = ['part_of_speech_fk']
